package encapsulation;

/**
 * @classname:Person
 * @description:
 * @author: Mr.Z
 * @date: 2020/11/27 22:39
 * @version: 0.1
 * @since:1.8
 */
public class Person {
    private static int count;
    private int id;
    private String name;
    private int age;

    public Person() {
        count++;
    }

    public Person(int id, String name, int age) {
        count++;
        this.id = id;
        this.name = name;
        this.age = age;
    }

    public static int getCount() {
        return count;
    }

    public static void setCount(int count) {
        Person.count = count;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
    public String compare(Person person){
        String result= this.getAge()>person.getAge()?"你的年龄较大":person.getName()+"年龄较大";
        if(this.getAge()==person.getAge()){
            return "你俩一样大";
        }
        return result;
    }
    public static void count(){
        System.out.println("一共创建了"+count+"个对象");
    }
}
